package com.scs.application.core.mvc.controller;


import com.scs.application.core.exceptions.ExportException;
import com.scs.application.core.exceptions.ImportException;
import com.scs.application.core.model.CommonResult;
import com.scs.application.core.model.ImportResult;
import com.scs.application.core.model.PageRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Description: 提供数据导入导出的接口定义
 */
public interface ImAndExAbleController<R extends PageRequest> {

    /**
     * excel导出
     *
     * @param request
     * @throws ExportException
     */
    @GetMapping("/excel/export")
    default void excelExport(R request) throws ExportException {
        throw new UnsupportedOperationException("不支持的操作");
    }


    /**
     * EXCEL模板
     *
     * @param request
     */
    @GetMapping("/excel/template")
    default void excelTemplate(R request) {
        throw new UnsupportedOperationException("不支持的操作");
    }


    /**
     * excel导入
     *
     * @param file 导入文件
     * @return
     * @throws ImportException
     */
    @PostMapping("/excel/import")
    default CommonResult<ImportResult> excelImport(MultipartFile file) throws ImportException {
        throw new UnsupportedOperationException("不支持的操作");
    }

    /**
     * CSV导出
     *
     * @param request
     * @throws ExportException
     */
    @GetMapping("/csv/export")
    default void csvExport(R request) throws ExportException {
        throw new UnsupportedOperationException("不支持的操作");
    }

}
